package com.ruoyi.contract.service.impl;

import java.util.List;

import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.contract.mapper.InvoiceInformationMapper;
import com.ruoyi.contract.domain.InvoiceInformation;
import com.ruoyi.contract.service.IInvoiceInformationService;

/**
 * 发票信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-10-18
 */
@Service
public class InvoiceInformationServiceImpl implements IInvoiceInformationService 
{
    @Autowired
    private InvoiceInformationMapper invoiceInformationMapper;

    /**
     * 查询发票信息
     * 
     * @param invoiceInformationId 发票信息主键
     * @return 发票信息
     */
    @Override
    public InvoiceInformation selectInvoiceInformationByInvoiceInformationId(Long invoiceInformationId)
    {
        return invoiceInformationMapper.selectInvoiceInformationByInvoiceInformationId(invoiceInformationId);
    }

    /**
     * 查询发票信息列表
     * 
     * @param invoiceInformation 发票信息
     * @return 发票信息
     */
    @Override
    public List<InvoiceInformation> selectInvoiceInformationList(InvoiceInformation invoiceInformation)
    {
        return invoiceInformationMapper.selectInvoiceInformationList(invoiceInformation);
    }

    /**
     * 新增发票信息
     * 
     * @param invoiceInformation 发票信息
     * @return 结果
     */
    @Override
    public AjaxResult insertInvoiceInformation(InvoiceInformation invoiceInformation)
    {
        List<InvoiceInformation> information = invoiceInformationMapper.selectInvoiceInformationList(invoiceInformation);
        if(information!=null&& !information.isEmpty()){
            return AjaxResult.error("公司名称不能相同");
        }
        return AjaxResult.success(invoiceInformationMapper.insertInvoiceInformation(invoiceInformation));
    }

    /**
     * 修改发票信息
     * 
     * @param invoiceInformation 发票信息
     * @return 结果
     */
    @Override
    public int updateInvoiceInformation(InvoiceInformation invoiceInformation)
    {
        return invoiceInformationMapper.updateInvoiceInformation(invoiceInformation);
    }

    /**
     * 批量删除发票信息
     * 
     * @param invoiceInformationIds 需要删除的发票信息主键
     * @return 结果
     */
    @Override
    public int deleteInvoiceInformationByInvoiceInformationIds(Long[] invoiceInformationIds)
    {
        return invoiceInformationMapper.deleteInvoiceInformationByInvoiceInformationIds(invoiceInformationIds);
    }

    /**
     * 删除发票信息信息
     * 
     * @param invoiceInformationId 发票信息主键
     * @return 结果
     */
    @Override
    public int deleteInvoiceInformationByInvoiceInformationId(Long invoiceInformationId)
    {
        return invoiceInformationMapper.deleteInvoiceInformationByInvoiceInformationId(invoiceInformationId);
    }
}
